package com.example.demo.controller;


import com.example.demo.entity.response.Response;
import com.example.demo.service.ProjectService;
import com.example.demo.utils.JsonUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
//@Api(tags ="项目接口")
@RestController
@RequestMapping("/project")
@CrossOrigin(origins = "*", maxAge = 3600)
public class ProjectController {

    @Autowired
    ProjectService projectService;


    @RequestMapping("list")
    public Response selectProjects(@RequestParam String data){
        int customerId = Integer.parseInt(JsonUtil.jsonToMap(data).get("customerId"));
        return projectService.selectProjectList(customerId);
    }


    @RequestMapping("details")
    public Response selectDetails(@RequestParam String data){

        Long projectId = Long.parseLong(JsonUtil.jsonToMap(data).get("projectId"));
        return projectService.selectProjectDetails(projectId);

    }
}
